
package com.baichang.taoshunda.controller;

import com.baichang.framework.controller.IController;
import com.baichang.framework.controller.IPageController;
import com.baichang.framework.controller.WebBaseController;
import com.baichang.framework.excelption.ServiceException;
import com.baichang.framework.model.Page;
import com.baichang.framework.security.entity.SAdmin;
import com.baichang.taoshunda.ControllerConstants;
import com.baichang.taoshunda.service.CashService;
import com.baichang.taoshunda.service.RedPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;

/**
 * 提现表
 */

@Controller
@RequestMapping(ControllerConstants.REDPACKAGE)
public class RedPackageController extends WebBaseController {
    @Autowired
    private RedPackageService redPackageService;

    @RequestMapping("/redpackage")
    public String redpackage(HttpServletRequest request, HttpServletResponse response) {
        return "/taoshunda/redpackage/redpackage";
    }




    /**
     * 获取红包记录列表
     *
     * @param request
     * @param response
     */
    @RequestMapping("/redpackageQuery")
    public void busscashQuery(HttpServletRequest request, HttpServletResponse response) {
        initPage(request, response, new IPageController() {
            @Override
            public Page initPage(HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServiceException {
                String bussName = getString(request, "bussName", "");
                String userName = getString(request, "userName", "");
                int status = getInt(request, "status", 0);
                return redPackageService.redPackageQuery(nowPage,pageSize,bussName,userName,status);
            }
        });
    }



    /**
     * 提现审核通过与审核失败
     */
    @RequestMapping("/deleteRedPackage")
    public void deleteRedPackage(HttpServletRequest request, HttpServletResponse response) {
        init(request, response, new IController() {
            @Override
            public Object initData(HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServiceException {
                int id = getInt(request, "id", 0);
                return redPackageService.deleteRedPackage(id);
            }
        });
    }



}
